﻿//
// User.cs
//
// Authors:
//    Claus Jørgensen <10229@iha.dk>
//
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics.Contracts;

namespace RSD.Data
{
    public partial class User
    {
        /// <summary>
        /// Determines whether the user been assigned the specified role.
        /// </summary>
        /// <param name="role">The specified role.</param>
        /// <returns>
        /// <c>true</c> if the user been assigned the specified role; otherwise, <c>false</c>.
        /// </returns>
        public bool IsInRole(string role)
        {
            Contract.Requires(this.UserGroups != null);

            return this.UserGroups.Any(x => x.Name == role);
        }
    }
}
